package org.bultreebank.document_repository.interfaces;

import java.util.List;
import java.util.Properties;

import org.w3c.dom.Document;

/**
 * These functions manipulate the documents and indexes internal 
 * presentation (identifiers, their relations)
 * @author Aneliya Tincheva
 *
 */
public interface IndexesDocumentsManager
{
	/**
	 * Deletes document ID from the index - document IDs table
	 * @param realIndexID: indexID
	 * @param docID: document ID to be deleted
	 * @throws Exception
	 */
	public void deleteDocumentForIndex(String realIndexID, String docID)throws Exception;
	/**
	 * Deleted document id from the index - document IDs table
	 * @param realIndexID - index ID defined by the user
	 * @throws Exception
	 */
	public void deleteDocsForIndex(String realIndexID)throws Exception;
	/**
	 * Returns a list of document IDs added to the indexed identified
	 * by the realIndexID 
	 * @param realIndexID - index ID defined by the user
	 * @return
	 * @throws Exception
	 */
	public List<String> getDocsForIndex(String realIndexID) throws Exception;
	/**
	 * Returns the document content of the document identified by docID,
	 * if a Document Repository exists
	 * @param docID - document ID
	 * @return
	 * @throws Exception
	 */
	public Document retrieveDocument(String docID) throws Exception;
	/**
	 * Adds entries in the system document ID - real document ID table and 
	 * in the real index ID - system document IDs table. Saves the file in
	 * the Document Repository if it exists. 
	 * @param realDocID - document identifier defined by the user
	 * @param internalDocID - system generated unique document identifier 
	 * @param realIndexID - system generated unique index identifier
	 * @param doc - content of the document that is being indexed
	 * @throws Exception
	 */
	public void addDocumentToIndex(String realDocID, String internalDocID,
			String realIndexID, Document doc) throws Exception;
	/**
	 * Adds entries in the system document ID - real document ID table and 
	 * in the real index ID - system document IDs table. The real document is already in
	 * the System Document Repository.
	 * @param realDocID
	 * @param realIndexID
	 * @throws Exception
	 */
	public void addDocumentToIndex(String realDocID,String realIndexID) throws Exception;
	/**
	 * Updates document identified by realDocID for the specified index,
	 * with its new content. This operation performs if a Document Repository
	 * exists.
	 * @param realDocID - document identifier defined by the user
	 * @param realIndexID - system generated unique index identifier
	 * @param doc - content of the document that is being indexed
	 * @throws Exception
	 */
	public void updateDocumentToIndex(String realDocID, String realIndexID,
			Document doc) throws Exception;
	/**
	 * Returns the system generated document ID, corresponding to the 
	 * realDocID, as defined in the system document ID - real document ID
	 * table
	 * @param realDocID - document identifier defined by the user
	 * @return
	 * @throws Exception
	 */
	public String getInternalDocID(String realDocID) throws Exception;
	/**
	 * Returns the user defined document ID, corresponding to the 
	 * internalDocID, as defined in the system document ID - real document ID
	 * table
	 * @param internalDocID - system generated unique document identifier 
	 * @return
	 * @throws Exception
	 */
	public String getUserDocID(String internalDocID) throws Exception;
	/**
	 * Returns properties object that define the user defined document IDs and
	 * their corresponding system generated document IDs analogs.
	 * @return
	 */
	public Properties getAllUser_SystemDocs();
	/**
	 * Returns properties object that define the system generated document IDs and
	 * their corresponding user defined document IDs analogs.
	 * @return
	 */
	public Properties getAllSystem_UserDocs();
	/**
	 * Returns the path to the Document Repository if exists
	 * @return
	 */
	public String getIndexDocsRepositoryPath();

}
